<template>
  <div class="home">

    <van-grid>
      <van-grid-item 
          v-for="(item, index) in filterList" 
          @click="click(item.auth)"
          :icon="item.icon"
          :key="index" 
          :text="item.title" />
    </van-grid>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
export default {
  name: "Home",
  computed: {
    ...mapState(["list"]),
    filterList() {
      return this.list.filter(item => item.flag)
    }
  },
  created() {
    if (this.list.length === 0) {
      this.INIT_LIST()
    }
  },
  methods: {
    ...mapActions(["INIT_LIST"]),
    click(auth) {
      if (auth) {
        this.$router.push('/list')
      }
    }
  }
};
</script>
